Tutorial: Create a custom search engine and question-answering system
In this tutorial, learn how to index and query large data loaded from a Spark cluster. You set up a Jupyter Notebook that performs the following actions:
- Load various forms (invoices) into a data frame in an Apache Spark session
- Analyze them to determine their features
- Assemble the resulting output into a tabular data structure
- Write the output to a search index hosted in Azure Cognitive Search
- Explore and query over the content you created
1 - Set up dependencies
We start by importing packages and connecting to the Azure resources used in this workflow.
%pip install openai==2.47.0
from synapse.ml.core.platform import find_secret
cognitive_key = find_secret(
secret_name="ai-services-api-key", keyvault="mmlspark-build-keys"
) # Replace the call to find_secret with your key as a python string. e.g. cognitive_key="27snaiw..."
cognitive_location = "eastus"
translator_key = find_secret(
secret_name="translator-key", keyvault="mmlspark-build-keys"
) # Replace the call to find_secret with your key as a python string.
translator_location = "eastus"
search_key = find_secret(
secret_name="azure-search-key", keyvault="mmlspark-build-keys"
) # Replace the call to find_secret with your key as a python string.
search_service = "mmlspark-azure-search"
search_index = "form-demo-index-5"
openai_key = find_secret(
secret_name="openai-api-key-3", keyvault="mmlspark-build-keys"
) # Replace the call to find_secret with your key as a python string.
openai_service_name = "synapseml-openai-3"
openai_deployment_name = "gpt-5-mini"
openai_url = f"https://{openai_service_name}.openai.azure.com/"